package com.zhangjun.work5.controller;

import com.zhangjun.work5.entity.Student;
import com.zhangjun.work5.entity.TransferForm;
import com.zhangjun.work5.service.TransferService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author 张钧
 * @Description
 * @create 2022-11-11 11:06
 */
@RestController
@RequestMapping("/transfer")
public class TransferController {

	@Resource
	private TransferService transferService;

	@GetMapping
	public List<Student> getStudents(){
		return transferService.getStudents();
	}

	@PostMapping
	public String transferBalance(@RequestBody TransferForm transferForm){
		if(BigDecimal.ZERO.compareTo(transferForm.getMoney()) != -1){
			return "转账失败，输入金额为"+ transferForm.getMoney();
		}
		transferService.transferBalance(transferForm);
		return "转账成功";
	}
}
